package org.procrastinationapp.web;

import org.apache.wicket.authentication.AuthenticatedWebApplication;
import org.apache.wicket.authentication.AuthenticatedWebSession;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.protocol.http.WebRequestCycleProcessor;
import org.apache.wicket.protocol.http.request.CryptedUrlWebRequestCodingStrategy;
import org.apache.wicket.protocol.http.request.WebRequestCodingStrategy;
import org.apache.wicket.request.IRequestCodingStrategy;
import org.apache.wicket.request.IRequestCycleProcessor;
import org.apache.wicket.spring.injection.annot.SpringComponentInjector;
import org.procrastinationapp.web.pages.HomePage;
import org.procrastinationapp.web.pages.UserForm;
import org.procrastinationapp.web.pages.UserList;
import org.procrastinationapp.web.pages.aaa.MyAuthenticatedWebSession;
import org.procrastinationapp.web.pages.aaa.MySignInPage;

public class Application extends AuthenticatedWebApplication {

	protected void init() {
		super.init();

		addComponentInstantiationListener(new SpringComponentInjector(this));

		// Session.get().setLocale(new Locale("es", "ES"));

		// make bookmarkable pages for easy linking from Menu
		mountBookmarkablePage("/users", UserList.class);
		mountBookmarkablePage("/userform", UserForm.class);
	}

	@Override
	public Class<HomePage> getHomePage() {
		return HomePage.class;
	}

	@Override
	protected Class<? extends WebPage> getSignInPageClass() {
		return MySignInPage.class;
	}

	@Override
	protected Class<? extends AuthenticatedWebSession> getWebSessionClass() {
		return MyAuthenticatedWebSession.class;
	}

	@Override
    protected IRequestCycleProcessor newRequestCycleProcessor() {
        return new WebRequestCycleProcessor() {
            protected IRequestCodingStrategy newRequestCodingStrategy() {
                return new CryptedUrlWebRequestCodingStrategy(
                        new WebRequestCodingStrategy());
            }
        };
    }
}